home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / misc / pdflib / p_intern.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  5KB  |  186 lines

  1. /* p_intern.h
  2.  * Copyright (C) 1997-98 Thomas Merz. All rights reserved.
  3.  *
  4.  * PDFlib internal definitions
  5.  */
  6.  
  7. #ifndef P_INTERN_H
  8. #define P_INTERN_H
  9.  
  10. #include "pdf.h"
  11.  
  12. /* Several limits -- change if too small (or too large) */
  13. #define MAX_CONTENTS    512        /* maximum number of content sections */
  14.  
  15. #ifndef DOS
  16. #define MAX_ID        ((id) 10000)    /* maximum number of objects in file */
  17. #define MAX_PAGES     1000        /* maximum number of pages in file */
  18. #else
  19. #define MAX_ID        ((id) 1000)
  20. #define MAX_PAGES     100
  21. #endif
  22.  
  23. typedef enum { ImageB = 1, ImageC = 2, ImageI = 4, Text = 8 } pdf_procset;
  24.  
  25. typedef enum { 
  26.     res_procset, res_font, res_encoding, 
  27.     res_fontdescriptor, res_colorspace, res_xobject
  28. } pdf_res_type;
  29.  
  30. typedef enum { c_none, c_stream, c_text } pdf_content_type;
  31.  
  32. typedef long id;
  33.  
  34. #define NEW_ID        0L
  35. #define BAD_ID        -1L
  36.  
  37. /* Note: pdf_begin_obj() is a function */
  38. #define pdf_end_obj(p)        (void) fputs("endobj\n", p->fp)
  39.  
  40. #define pdf_begin_dict(p)    (void) fputs("<<", p->fp)
  41. #define pdf_end_dict(p)        (void) fputs(">>\n", p->fp)
  42.  
  43. #define pdf_begin_stream(p)    (void) fputs("stream\n", p->fp)
  44. #define pdf_end_stream(p)    (void) fputs("endstream\n", p->fp)
  45.  
  46. typedef struct {
  47.     char    *name;
  48.     float    size;
  49.     FILE    *file;
  50.     char    fontName[64];        /* AFM key: FontName */
  51.     char    weight[64];        /* AFM key: Weight */
  52.     char    encodingScheme[64];    /* AFM key: EncodingScheme */
  53.     float    italicAngle;        /* AFM key: ItalicAngle */
  54.     bool    isFixedPitch;        /* AFM key: IsFixedPitch */
  55.     int        llx;            /* AFM key: FontBBox */
  56.     int        lly;            /* AFM key: FontBBox */
  57.     int        urx;            /* AFM key: FontBBox */
  58.     int        ury;            /* AFM key: FontBBox */
  59.     int        underlinePosition;      /* AFM key: UnderlinePosition */
  60.     int        underlineThickness;     /* AFM key: UnderlineThickness */
  61.     int        capHeight;        /* AFM key: CapHeight */
  62.     int        ascender;        /* AFM key: Ascender */
  63.     int        descender;        /* AFM key: Descender */
  64.     int        StdVW;            /* AFM key: StdVW */
  65.     int        StdHW;            /* AFM key: StdHW */
  66.     PDF_encoding    encoding;
  67.     int            FontWidths[256];    /* From AFM char metrics and encoding */
  68. } pdf_font;
  69.  
  70. typedef struct pdf_item_s pdf_item;
  71. struct pdf_item_s {
  72.     char    *name;
  73.     char    *basename;
  74.     id        obj_id;
  75.     pdf_item    *next;
  76. };
  77.  
  78. typedef struct {
  79.     pdf_procset    procset;
  80.     pdf_item    *font;
  81.     pdf_item    *encoding;
  82.     pdf_item    *fontdescriptor;
  83.     pdf_item    *colorspace;
  84.     pdf_item    *xobject;
  85. } pdf_res;
  86.  
  87. typedef struct {
  88.     id        self;        /* id of this outline object */
  89.     id        parent;        /* ancestor's id */
  90.     id        prev;        /* previous entry at this level */
  91.     id        next;        /* next entry at this level */
  92.     id        first;        /* first sub-entry */
  93.     id        page;        /* id of destination page */
  94.     char     *text;        /* bookmark text */
  95. } pdf_outline;
  96.  
  97. struct PDF_s {
  98.     FILE    *fp;
  99.  
  100.     /* general stuff */
  101.     PDF_info    *info;
  102.     id        currentobj;
  103.  
  104.     id        root_id;
  105.     id        info_id;
  106.     id        pages_id;
  107.     id        outlines_id;
  108.     id        open_action;
  109.  
  110.     long    file_offset[MAX_ID];
  111.     id        pages[MAX_PAGES];
  112.     int        font_number;
  113.     int        xobject_number;
  114.     int        image_number;
  115.     int        open_outlines;
  116.     int        outline_count;            /* HACK */
  117.     pdf_outline    outlines[MAX_PAGES];        /* HACK */
  118.  
  119.     /* page specific stuff */
  120.     id        res_id;
  121.     id        contents_length;
  122.     id        contents_ids[MAX_CONTENTS];
  123.     id        next_content;
  124.     pdf_content_type    contents;
  125.     PDF_transition    transition;
  126.     float    duration;
  127.  
  128.     pdf_res    res;
  129.     int     current_page;
  130.     long    start_contents_pos;
  131.  
  132.     float    width;
  133.     float    height;
  134.  
  135.     /* general graphics state */
  136.     /* NYI */
  137.  
  138.     /* text state */
  139.     float    char_spacing;
  140.     float    leading;
  141.     pdf_font    *current_font;
  142.  
  143.     /* miscellaneous */
  144.     int        chars_on_this_line;
  145. };
  146.  
  147. /* p_basic.c */
  148. extern const char    *pdf_filter_names[compression_count];
  149. extern const char    *pdf_colorspace_names[colorspace_count];
  150. extern const char    *pdf_encoding_names[encoding_count];
  151. void    pdf_begin_contents_section(PDF *p);
  152. void    pdf_end_contents_section(PDF *p);
  153. void    pdf_default_error_handler(int level, const char* fmt, va_list ap);
  154. void    pdf_error(PDF *, int level, const char *fmt, ...);
  155. id    pdf_begin_obj(PDF *p, id obj_id);
  156. id    pdf_alloc_id(PDF *p);
  157. pdf_item *pdf_add_res_font(PDF *p, char *basename);
  158. void    pdf_add_res_xobject(PDF *p, id xobj_id);
  159.  
  160. /* p_text.c */
  161. void pdf_put_fonts(PDF *p);
  162. void pdf_begin_text(PDF *p);
  163. void pdf_end_text(PDF *p);
  164. void pdf_quote_string(PDF *p, char *string);
  165.  
  166. /* p_draw.c */
  167. void pdf_concat(PDF *p, PDF_matrix m);
  168.  
  169. /* p_image.c */
  170.  
  171. /* p_filter.c */
  172. void pdf_ASCII85Encode(PDF *p, PDF_data_source *src);
  173. void pdf_ASCIIHexEncode(PDF *p, PDF_data_source *src);
  174.  
  175. /* p_font.c */
  176. bool pdf_read_afm(PDF *p, char *fontname, PDF_encoding enc);
  177. void pdf_put_t1font(PDF *p, char *fontname, id font_id, int fontnumber, bool embed);
  178.  
  179. /* p_util.c */
  180. char    *pdf_float(float f);
  181.  
  182. /* p_hyper.c */
  183. void pdf_write_outlines(PDF *p);
  184.  
  185. #endif                /* P_INTERN_H */
  186.